#include "widget.h"
#include "ui_widget.h"
#include <QPainter>
#include <QBitmap>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}
void Widget::paintEvent(QPaintEvent *)
{
    /*
    QPainter painter(this);
    QPen pen(QColor(255,0,0));
    pen.setWidth(3);
    painter.setPen(pen);
    painter.drawLine(QPoint(0, 0), QPoint(200, 200));
    painter.drawEllipse(QPoint(200,200), 100, 100);
    painter.drawRect(QRect(50,50,100,100));
    painter.drawText(QRect(50,50,100,100), "好好学习，天天向上");
    */
    // 高级
    QPainter apainter(this);
    apainter.drawEllipse(QPoint(200,100),100,100);
    // 抗锯齿
    apainter.translate(100,0);
    apainter.setRenderHint(QPainter::Antialiasing);
    apainter.drawEllipse(QPoint(400,100),100,100);

    // 画图片
    apainter.translate(-97,3);
    apainter.drawPixmap(0,0,QPixmap(":/jtl.jpg").scaled(600,337));
    apainter.translate(0,340);
    apainter.drawPixmap(0,0,QBitmap(":/jtl.jpg").scaled(600,337));
}
